# # from urllib.parse import urlencode
# #
# from time import sleep
# # from urllib.parse import urlparse
# # url="https://www.digikey.com.cn/product-detail/zh/omron-automation-and-safety/K7L-AT50/Z5905-ND/598115"
# # print(urlparse(url).netloc)
#
# from selenium import webdriver
# from selenium.common.exceptions import TimeoutException
# from selenium.webdriver.common.by import By
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from selenium.webdriver.common.proxy import Proxy
# from selenium.webdriver.common.proxy import ProxyType
# from pyquery import PyQuery as pq
# import requests
# url="http://www.ic.net.cn/search.php?IC_Method=icsearch&key=S87C751-1DB&isExact=0&mfg=&pack=&dc=&qty=&searchAreaCode=0&stockDate=90&stockType=0&page=1&sort="
#
# import os
# path="/digikey_html"
# path=path.strip()
# path=path.rstrip('\\')
# isexists=os.path.exists(path)
# if not isexists:
#     os.mkdir(path)
# else:
#     print("目录存在")
import re
a=re.sub(" ","","传感器 - 配件")
print(a)
# def get_proxy(port):
#     url = "http://localhost:{port}/random"
#     proxy = requests.get(url.format(port=port)).text
#     doc = pq(proxy)
#     if doc('.debugger'):
#         proxy = None
#     else:
#         proxy = str(proxy)
#     print("***********using proxy**************:", proxy)
#     return proxy
#
# # PhantomJS配置
# SERVICE_ARGS = ['--load-images=false', '--disk-cache-path=false']
# browser = webdriver.PhantomJS(service_args=SERVICE_ARGS)
# proxy = webdriver.Proxy()
# proxy.proxy_type = ProxyType.MANUAL
# proxy.http_proxy = "14.118.254.180:6666"
# # 将代理设置添加到webdriver.DesiredCapabilities.PHANTOMJS中
# proxy.add_to_capabilities(webdriver.DesiredCapabilities.PHANTOMJS)
# browser.start_session(webdriver.DesiredCapabilities.PHANTOMJS)
# wait = WebDriverWait(browser, 5)
# browser.implicitly_wait(5)
# browser.set_page_load_timeout(5)
# browser.get(url)
# wait.until(
#     EC.presence_of_element_located((By.CSS_SELECTOR, ".right_results"))
# )
# print(browser.page_source)
# doc=pq(browser.page_source)
# text=doc(".result_icons .iccp")
# print(text)
#
# # import requests
# # header = {
# #   'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
# #   'Accept-Language': 'zh-CN,zh;q=0.9',
# #   'Cache-Control': 'max-age=0',
# #   'Connection': 'keep-alive',
# #   'Host': 'www.digikey.com.cn',
# #   'Upgrade-Insecure-Requests': '1',
# #   'Referer':'https://www.digikey.com.cn/products/zh/%E4%BC%A0%E6%84%9F%E5%99%A8-%E5%8F%98%E9%80%81%E5%99%A8/%E4%B8%93%E7%94%A8%E4%BC%A0%E6%84%9F%E5%99%A8/561?pageNumber=1',
# #   'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36',
# # }
# # url="https://www.digikey.com.cn/product-detail/zh/omron-automation-and-safety/K7L-AT50/Z5905-ND/598115"
# # url1="https://www.digikey.com.cn/product-detail/zh/maxim-integrated/MAX86141ENP-T/MAX86141ENP-TTR-ND/7804058"
# # #r = requests.get(url,headers=header,allow_redirects=False)
# # r=urlencode({"key":"MAX30105EFD+"})
# # print(r)
# #
# import urllib.request
# from pyquery import PyQuery as pq
# import pymysql
# # db= pymysql.connect(host="localhost",user="root",
# #      password="mysql01216016",db="digikey_icnet",port=3306,charset='utf8')
# # cursor=db.cursor()
# # item={'Encapsulation': '',
# #  'Manufacturer': 'Panasonic Industrial Automation Sales',
# #  'Part_Number': 'EX-F71',
# #  'class1': '传感器，变送器',
# #  'class2': '专用传感器',
# #  'dj_Part_Number': '1110-1879-ND',
# #  'img_url': '//media.digikey.com/photos/Panasonic%20Photos/EX-F71.jpg',
# #  'url': 'https://www.digikey.com.cn/product-detail/zh/panasonic-industrial-automation-sales/EX-F71/1110-1879-ND/3899411'}
# # import re
# # s=re.sub(r"\+|-","","6565+646-",re.S)
# # print(s)
#
# '''
#
# '''
# #
# # effect_row = cursor.execute(
# #     "replace into company_info(Company_Name,Part_Number,Levels,User_Date,ContactMan,Telephone,Mobilephone,Facsimile,Office_address,QQ,address,Batch_Number,Inventory,Pacakage,Remarks,Issue_Date,Grap_Date)values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
# #     (item['Name'], item['Part_Number'], item['Level'], item['User_Date'], item['ContactMan'], item['Telephone'],
# #     item['Mobilephone'], item['Facsimile'], item['Office_address'], item['QQ'], item['address'], item['Batch_Number'],
# #     item['Inventory'], item['Pacakage'], item['Remarks'], item['Issue_Date'], item['Grap_Date']))
# #e=cursor.execute('replace into dollar_exchange_rate(Grap_time,Exchange_rate) VALUES("2018-1-1","2.33")')
# # effect_row = cursor.execute("insert into parts_price_dollar(Part_Number,Num,Num_Low,Num_Higher,Unit_Price_Dollar,Grab_Time)values(%s,%s,%s,%s,%s,%s)",
# #                                                  (item['Part_Number'],item['Number'],item['Num_Low'],item['Num_Higher'],item['Unit_Price_Dollar'],item['Grab_Time']))
# # effect_row = cursor.execute("REPLACE into parts_detail(Part_Number,Manufacturer,Encapsulation,class1,class2,img_url,url，dj_Part_Number)values(%s,%s,%s,%s,%s,%s,%s,)",
# #     (item['Part_Number'], item['Manufacturer'], item['Encapsulation'], item['class1'], item['class2'], item['img_url'],
# #      item['url']))
# #
# # db.commit()
# # db.close()
# # import re
#
# # url="https://www.digikey.com.cn/product-detail/zh/nohm-semiconductor/RPI-0126K/511-1630-6-ND/1952894"
# #
# #
# # print(p[-2])
# # if "MAX86141ENP-TTR-ND"!="MAX86141ENP-TTR-ND":
# #     print('1')
# # else:
# #     print("2")
# #
# # def getHtml(url):
# #   html = urllib.request.urlopen(url).read()
# #   return html
#
# # def saveHtml(file_name, file_content):
# #   #    注意windows文件命名的禁用符，比如 /
# #   with open(file_name.replace('/', '_') + ".html", "wb") as f:
# #     #   写文件用bytes而不是str，所以要转码
# #     f.write(file_content)
# #aurl = "http://www.ic.net.cn/search.php?IC_Method=icsearch&key=AD620AR&isExact=0&mfg=&pack=&dc=&qty=&searchAreaCode=0&searchMarket=&stockDate=90&stockType=0&page={page}&sort="
# # doc=pq(s)
# # for i in range(1,10):
# #   sleep(2)
# #   s = requests.get(aurl.format(page=i))
# #   print(s.status_code)
# #   #print(s.text)
# #   doc = pq(s.text)
# #   t=doc(".result_icons .sscp")
# #   print(t)
# # def get_prox():
# #   proxy = requests.get('http://localhost:5000/get').text
# #   proxy = 'http://' + str(proxy)
# #   return proxy
# #
# # p=get_prox()
# # print(p)
# # doc=pq(html)
# # doc()
# # r=doc(".stair_tr:gt(0)")
# # for i in r.items():
# #   s=i('.result_supply .result_goCompany').attr('title')
# #   print(s)
# #
# #s=r(".result_icons .sscp")
# # i=doc(".result_icons .iccp")
# # c=doc('.sorrytishi')
#
